package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.DeleteUserMsgService;
import com.zr.service.impl.DeleteUserMsgServiceImpl;

import net.sf.json.JSONObject;

/**
 * 处理删除选中用户信息请求
 * @author lzq
 *
 */
public class DeleteUserMsgAction extends HttpServlet{
	private DeleteUserMsgService deleteUserMsgService = new DeleteUserMsgServiceImpl();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setCharacterEncoding("utf-8");
		String[] unames = req.getParameterValues("unames[]");
		boolean b = deleteUserMsgService.getDeleteUserMsgByUnames(unames);
		PrintWriter pw = resp.getWriter();
		JSONObject json = new JSONObject();
		if(b){
			json.put("success", true);
			json.put("msg", "删除成功!");
		}else{
			json.put("success", false);
			json.put("msg", "删除失败!");
		}
		pw.write(json.toString());
		pw.flush();
	}
}
